import shutil
import os
import zipfile

# --- 压缩 ---

# 将当前目录压缩为 /tmp/python全栈.zip
# shutil.make_archive("/tmp/python全栈", "zip", os.getcwd())

# 将指定文件压缩到一个zip文件
z = zipfile.ZipFile("/tmp/foo.zip", "w")
z.write(__file__)
z.close()

# --- 解压 ---

z = zipfile.ZipFile("/tmp/foo.zip", "r")
z.extractall("/tmp")
z.close()
